package com.groupbuying.currency.producer.service.impl;

import com.groupbuying.currency.producer.constants.CurrencyPrepayInfoEnumConstants;

import com.groupbuying.currency.producer.utils.currencyOperUtils.DateFormatHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.groupbuying.currency.producer.dao.CurrencyPrepayInfoDao;
import com.groupbuying.currency.producer.domain.CurrencyPrepayInfoDO;
import com.groupbuying.currency.producer.service.CurrencyPrepayInfoService;



@Service
public class CurrencyPrepayInfoServiceImpl implements CurrencyPrepayInfoService {
	@Autowired
	private CurrencyPrepayInfoDao currencyPrepayInfoDao;
	
	@Override
	public CurrencyPrepayInfoDO get(String prepayId){
		return currencyPrepayInfoDao.get(prepayId);
	}
	
	@Override
	public List<CurrencyPrepayInfoDO> list(Map<String, Object> map){
		return currencyPrepayInfoDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return currencyPrepayInfoDao.count(map);
	}
	
	@Override
	public int save(CurrencyPrepayInfoDO currencyPrepayInfo){
		return currencyPrepayInfoDao.save(currencyPrepayInfo);
	}
	
	@Override
	public int update(CurrencyPrepayInfoDO currencyPrepayInfo){
		return currencyPrepayInfoDao.update(currencyPrepayInfo);
	}
	
	@Override
	public int remove(String prepayId){
		return currencyPrepayInfoDao.remove(prepayId);
	}
	
	@Override
	public int batchRemove(String[] prepayIds){
		return currencyPrepayInfoDao.batchRemove(prepayIds);
	}

    @Override
    public CurrencyPrepayInfoDO queryPayStateByOrderNum(String orderNum) {
        Map map = new HashMap();
        map.put("orderNum", orderNum);
        map.put("delFlag", "1");
        List<CurrencyPrepayInfoDO> list = this.list(map);
        return list != null && list.size() > 0 ? list.get(0) : null;
    }
      @Override
    public void updatePrepayInfo(CurrencyPrepayInfoDO currencyPrepayInfo){

        currencyPrepayInfo.setCreateTime(DateFormatHelper.getNowTimeStr());
        currencyPrepayInfo.setOpeTime(DateFormatHelper.getNowTimeStr());
        currencyPrepayInfo.setBusinessType(CurrencyPrepayInfoEnumConstants.ENUM_BUSINESSTYPE_CURRENCYADD+"成功");
        currencyPrepayInfo.setState(CurrencyPrepayInfoEnumConstants.Return_integral);

            this.update(currencyPrepayInfo);



    }

}


